package com.fileDemo;

import java.io.IOException;
import java.io.ObjectInputStream;
import java.nio.file.Files;
import java.nio.file.Paths;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: FENGYiMing
 * @Date: 2024/04/10/10:48
 * @Description:
 */
public class ObjectInputStream01 {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //读取时必须按照写入的顺序进行读取
        ObjectInputStream ois = new ObjectInputStream(Files.newInputStream(Paths.get("e:/oop.bat")));
        System.out.println(ois.readInt());
        System.out.println(ois.readBoolean());
        System.out.println(ois.readChar());
        System.out.println(ois.readFloat());
        System.out.println(ois.readUTF());
        Object o = ois.readObject();
        Dog dog = (Dog) o;
        dog.speak();
        System.out.println(dog.getName());
        System.out.println(o);
    }
}
